<?php
//  路由
use think\facade\Route;

Route::get('/','index/welcome');
Route::get('/php','index/phpinfo');
Route::get('password','index/password');

/*******************************Login*******************************/
Route::post('api/login', 'auth/login');

/*******************************User*******************************/
Route::group('api/user', function () {
    Route::get('info', 'user/info')
        ->middleware(\app\middleware\RBACAuth::class,'user:info');

    Route::get('get_logininfo','userloginlog/getLastLoginInfo')
        ->middleware(\app\middleware\RBACAuth::class,'user:logininfo');
    Route::post('set_logininfo','userloginlog/setLastLoginInfo')
        ->middleware(\app\middleware\RBACAuth::class,'user:logininfo');


    Route::get('list', 'user/list')
        ->middleware(\app\middleware\RBACAuth::class,'user:list');
    Route::post('save', 'user/save')
        ->middleware(\app\middleware\RBACAuth::class,'user:save');
    Route::delete('delete', 'user/delete')
        ->middleware(\app\middleware\RBACAuth::class,'user:delete');
    Route::delete('all_delete', 'user/all_delete')
        ->middleware(\app\middleware\RBACAuth::class,'user:alldelete');
    Route::post('assign_roles','userrole/assign_roles')
        ->middleware(\app\middleware\RBACAuth::class,'user:assignroles');
    Route::delete('unassign_roles','userrole/unassign_roles')
        ->middleware(\app\middleware\RBACAuth::class,'user:unassignroles');
    Route::get('roles','userrole/roles')
        ->middleware(\app\middleware\RBACAuth::class,'user:roles');
})->middleware([\app\middleware\JwtAuth::class]);

/*******************************Role*******************************/
Route::group('api/role', function () {
    Route::get('list', 'role/list')
        ->middleware(\app\middleware\RBACAuth::class,'role:list');
    Route::post('save', 'role/save')
        ->middleware(\app\middleware\RBACAuth::class,'role:save');
    Route::delete('delete', 'role/delete')
        ->middleware(\app\middleware\RBACAuth::class,'role:delete');
    Route::get('users','userrole/users')
        ->middleware(\app\middleware\RBACAuth::class,'role:users');
    Route::post('assign_perms','rolepermission/assign_permissions')
        ->middleware(\app\middleware\RBACAuth::class,'role:assignpermissions');
    Route::delete('unassign_perms','rolepermission/unassign_permissions')
        ->middleware(\app\middleware\RBACAuth::class,'role:unassignpermissions');
    Route::get('perms','rolepermission/perms')
        ->middleware(\app\middleware\RBACAuth::class,'role:permissions');
    Route::delete('all_delete', 'role/all_delete')
        ->middleware(\app\middleware\RBACAuth::class,'role:alldelete');
})->middleware([\app\middleware\JwtAuth::class]);

/*******************************Permission*******************************/
Route::group('api/permission', function () {
    Route::get('/', 'permission/list')
        ->middleware(\app\middleware\RBACAuth::class,'permission:list');
    Route::get('list', 'permission/tree')
        ->middleware(\app\middleware\RBACAuth::class,'permission:treelist');
    Route::post('save', 'permission/save')
        ->middleware(\app\middleware\RBACAuth::class,'permission:save');
    Route::delete('delete', 'permission/delete')
        ->middleware(\app\middleware\RBACAuth::class,'permission:delete');
    Route::get('roles','rolepermission/roles')
        ->middleware(\app\middleware\RBACAuth::class,'permission:roles');
})->middleware([\app\middleware\JwtAuth::class]);